﻿import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './CategoryHeader.css'

export default class CategoryHeader extends Component {
    static propTypes = {
        title: PropTypes.string.isRequired,
        pageCount: PropTypes.number.isRequired,
        currentPage: PropTypes.number.isRequired,
        move2pre: PropTypes.func.isRequired,
        move2next: PropTypes.func.isRequired
    }
    render() {
        var { title, pageCount, currentPage } = this.props;
        return (
            <div className='his-cat-head'>
                <div className='his-cat-title'>{title}</div>
                <div>
                    <button
                        disabled={currentPage===0}
                        onClick={() => this.props.move2pre()}>上一页</button>
                    <span>{currentPage+1}/{pageCount}</span>
                    <button
                        disabled={currentPage + 1 >= pageCount}
                        onClick={() => this.props.move2next()}>下一页</button>
                </div>
            </div>
        )
    }
}